// Win32DLLDemoUseDLL7.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <Windows.h>

typedef int (*ADD)(int, int); // 定义函数指针

int main()
{
    /* 在Win32方式下生成的动态链接库不但可以提供给C++语言使用，也可以提供给其他语言使用，比如Delphi、VB、C#等，这样使得掌握不同语言的开发人员可以进行联合开发，
     *   而不必要求大家都使用同一种开发语言。其他语言调用C/C++开发的动态链接库时必须要处理好两个问题：一个是函数调用的约定；另一个是函数名修饰的约定。
    */
    std::cout << "Hello World!\n";
    HINSTANCE hDLL = LoadLibraryA("QtC__LibraryDemo.dll");
    if (hDLL != NULL)
    {
        ADD add = (ADD)GetProcAddress(hDLL, "add"); // 实例化回调函数指针
        std::cout << "sum:" << add(2, 3) << std::endl;
        FreeLibrary(hDLL); // 
    }
    else
        std::cout << "LoadLibrary failed\n" << std::endl;

    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
